package com.ccsu.eb.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ccsu.eb.mapper.EbProductCategoryMapper;
import com.ccsu.eb.mapper.EbProductMapper;
import com.ccsu.eb.model.EbProduct;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * @Description: 用一句话描述
 * @Auther: 新梦想*陈超
 * @Date: 2022/3/17 09:33
 */
@Service//证
public class IndexService {

    @Resource
    private EbProductMapper ebProductMapper;

    @Resource
    private EbProductCategoryMapper ebProductCategoryMapper;

    public Map<String,Object> index(int pnum){
        Map<String,Object> result =  new HashMap();
        //TODO 1.分页查询商品数据  默认第1页 每页8条数据
        Page<EbProduct> page = new Page<>(pnum,8);
        Page<EbProduct> ebProductPage = ebProductMapper.selectPage(page, null);
        //TODO 2.分页查询新闻数据  第1页 每页7条数据  按时间降序排序

        //TODO 3.查询商品分类数据
        //List<EbProductCategory> bigCateList = ebProductCategoryMapper.selectList(new QueryWrapper<EbProductCategory>()
        //        .apply("epc_id=epc_parent_id"));
        //List<EbProductCategory> smallCateList = ebProductCategoryMapper.selectList(new QueryWrapper<EbProductCategory>()
        //        .apply("epc_id!=epc_parent_id"));

        //TODO  4.将数据封装的到Map集合
        result.put("productPage",ebProductPage);
        //result.put("bigCateList",bigCateList);
        //result.put("smallCateList",smallCateList);
        return  result;

    }
}
